﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Sockets;
using System.IO;
using OrchardSystemServer.Database;

namespace OrchardSystemServer.Account
{
    public class ConnectionClient
    {
        public TcpClient Client { get; private set; }

        public StreamReader reader { get; private set; }
        public StreamWriter writer { get; private set; }
        public string UserName { get; set; }
        public string UserSocketDescription { get; set; }
        public CommandExecutor commandExecutor;

        public ConnectionClient(TcpClient client)
        {
            this.Client = client;
            NetworkStream networkStream = client.GetStream();

            reader = new StreamReader(networkStream,Encoding.UTF8);
            writer = new StreamWriter(networkStream, Encoding.UTF8);
            UserSocketDescription = Client.Client.RemoteEndPoint.ToString();
            commandExecutor=new CommandExecutor();
        }

        public void Close()
        {
            try
            {
                reader.Close();
                writer.Close();
                Client.Close();
            }
            catch (Exception) { return; }
        }
    }
}
